<?=view("home.common.header")?>
<div class="container-fluid">
        <div class="row">
            <div class="col-xs-12 col-sm-12 bottom-line">
                <i class="glyphicon glyphicon-chevron-right jt"></i><span class="headfont">在线选购<?= $pcate->rate?>套餐</span>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12 col-sm-12">
                <div class="sh font14">亲爱的 <kbd class="blue"><?=$plot->name?></kbd> 用户您好,<br/>　　　　便于与您联系,请如实填写信息</div>
                <div class="kdsl">填写信息</div>
                <form id="payform" action="" method="post">
                    <select class="form-control" name="productid" id="product" onchange="modPrice(this)">
                        <option value="">--套餐选择--</option>
                        <?php if ($products && count($products)): ?>
                        <?php foreach ($products as $val): ?>
                        <option value="<?=$val->id?>" data-price="<?= $val->price?> " data-plotfav="<?=$val->strPlotFav($request->input('plot'), 1)?>" data-plotinit="<?=$val->strPlotFav($request->input('plot'), 2)?>" data-pfav="<?= $val->pfav ?>" <?php if ($request->input('productid', '') == $val->id):?>selected="selected"<?php endif; ?>><?=$val->name?></option>
                        <?php endforeach; ?>
                        <?php endif; ?>
                    </select>
                    <table class="table table-bordered mtop15">
                        <tr> 
                            <td>产品价格</td> 
                            <td>小区优惠</td>
                            <td>初装费用</td>
                            <td>平台优惠</td>
                            <td>实付金额</td>
                        </tr>
                        <tr> 
                            <td id="totalPrice"></td> 
                            <td id="plotFav"></td> 
                            <td id="plotInit"></td> 
                            <td id="pfav"></td> 
                            <td id="realPrice"></td>
                        </tr>
                    </table>
                    <?php if ($request->input('ptype') == 2): ?>
                    <input class="form-control" name="netname" placeholder="--请输入续费宽带帐号--" required="required"/>
                    <?php endif; ?>
                    <input class="form-control" name="name" type="text" value="<?=$request->input("name", '')?>" placeholder="--请输入用户姓名--">
                    <?php if ($request->input('ptype') == 1): ?>
                    <input class="form-control" required="required" name="cardnumber" type="text" value="<?=$request->input("cardnumber", '')?>" placeholder="--请输入用户身份证号--">
                    <?php endif; ?>
                    <input class="form-control" name="phone" type="text" value="<?=$request->input("phone", '')?>" placeholder="--请输入联系人电话--">
                    <input id="plot" name="plot" type="hidden" value="<?=$request->input("plot")?>" >
                     <?php if ($request->input('ptype') == 1): ?>
                    <input class="form-control" required="required" name="address" type="text" value="<?=$request->input("address", '')?>" placeholder="--户址（例：6号楼5单元3楼）--">
                    <?php endif; ?>
                    <input class="form-control" name="payphone" type="text" value="<?=$request->input("payphone", '')?>"  placeholder="--需要别人代付请填写代付人手机--">
                </form>
                <div><a class="evePay btn btn-success form-control" href="#" id="weixin">预订或支付</a></div>
            </div>
            <div class="col-xs-12 bqf col-sm-12 text-center"><?=config("global.site.global.footer")?></div>
        </div>
    </div>
    <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
    <script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
    <script src="<?=asset("js/function.js")?>"></script>
    <script>
        function modPrice(elem) {
            if (!$(elem).val()) {
                $('#totalPrice').html(""); 
                $("#pfav").html("");
                $("#plotFav").html("");
                $("#realPrice").html("");
                $( "#plotInit" ).val("");
                return;
            }
            var price = $("#product option:selected").attr('data-price'), pfav = $("#product option:selected").attr('data-pfav'),
                    plotfav = $("#product option:selected").attr('data-plotfav'),plotinit = $("#product option:selected").attr('data-plotinit');
            $('#totalPrice').html(price); 
            $("#pfav").html(pfav);
            $("#plotFav").html(plotfav);
            $( "#plotInit" ).html(plotinit);
            $("#realPrice").html(price - pfav - plotfav + parseInt(plotinit));
        }
        
        $(function(){
            $('.evePay').click(function(){
               var reg = /^1[3587]\d{9}$/;
               if ($('input[name=name]').val() == '') {
                   alert('请填写装机用户名');
                   $('input[name=name]').focus();
                   return false;
               }
//               if ($('input[name=cardnumber]').val() == '' || $('input[name=cardnumber]').val().length != 18) {
//                   alert('请正确填写用户身份证号');
//                   $('input[name=cardnumber]').focus();
//                   return false;
//               }
               if ($('input[name=phone]').val() == '' || !reg.test($('input[name=phone]').val())) {
                   alert('请填写正确的联系人电话');
                   $('input[name=phone]').focus();
                   return false;
               }
               if ($('input[name=plot]').val() == '') {
                   alert('所填小区不存在或没有填写');
                   $('input[name=plot]').focus();
                   return false;
               }
//               if($('input[name=address]').val() == '') {
//                   alert('请填写装机详细地址');
//                   $('input[name=address]').focus();
//                   return false;
//               }
               if($(this).attr('id') == 'weixin') {
                   if(!isWeiXin()) {
                       alert('请使用微信打开');
                       return false;
                   }
               }
               var type = $(this).attr('data-type');
               $("#ordt").val(type);
               $('#payform').submit();
               return false;
            });
        });
    </script>
	<script type="text/javascript" src="<?= asset("layer.m/layer.m.js")?>"></script>
    <script>
        var msg = '<?= $msg ?>';
        if (msg) {
            layer.open({
                content: msg,
                style: 'background-color:#09C1FF; color:#fff; border:none;',
                time: 2
            });
            window.setTimeout(function(){
                window.location.href = '<?=url("home/person/setinfo")?>'
            }, 2000);
        }
        var err = '<?= $err ?>';
        if (err) {
            layer.open({
                content: err,
                style: 'background-color:#09C1FF; color:#fff; border:none;',
                time: 2
            });
        }
    </script>
<?=view("home.common.footer")?>